function counter(n) {
  return {
    get count() {
      return n++;
    },
    set count(v) {
      if (v > n) n = v;
      else throw Error("count can only be set to a larger value");
    },
  };
}

let c = counter(1000);
console.log(c.count); // 1000
console.log(c.count); // 1001
c.count = 2000;
console.log(c.count); // 2000
// c.count = 2000;
